package jwanalytics.ejb.dataobjects;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

/** 
 * This is an analytical data storage event which will store page hit 
 * information. Notice that this is meant to be extensible to storing 
 * more fine grained events than just a page hit.
 * Such as: content item views, frequently asked question and answer views. */
public class JWAPageHitEvent extends JWAEvent implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	protected String pageName = null;
	
	protected Long returningBrowserKey = null;
	
	/** Session key which is passed from the web layer to the EJB server. */
	protected Long sessionKey = null;	
	
	protected HttpServletRequest request = null;
	
	/** 
	 * This must always be set to not null. So it is either a returning browser or an unique visitor to which you set the cookie in the first page and return.
	 * @param pageName.  This is how you decide to call the page for JWANalytics, this is not the page URL.  This gives you freedom to call a web page whatever you want.
	 * In the future there will even be a page version field so you can analyse a page and its multiple versions.
	 */	
	public JWAPageHitEvent(String pageName, Long returningBrowserKey, Long sessionKey, HttpServletRequest request) {
		if (request == null) {
			throw new IllegalStateException("Request cannot be null.");			
		}
		
		this.pageName = pageName;
		this.returningBrowserKey = returningBrowserKey;
		this.sessionKey = sessionKey;
		this.request = request;
	}
	
	public String getPageName() {
		return pageName;
	}
	
	public void setPageName(String pageName) {
		this.pageName = pageName;
	}
	
	public Long getReturningBrowserKey() {
		return returningBrowserKey;
	}
	
	public void setReturningBrowserKey(Long returningBrowserKey) {
		this.returningBrowserKey = returningBrowserKey;
	}
	
	public Long getSessionKey() {
		return sessionKey;
	}

	public void setSessionKey(Long sessionKey) {
		this.sessionKey = sessionKey;
	}
	
	public HttpServletRequest getRequest() {
		return request;
	}
	
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	
}
